import requests


# 定义员工管理的接口类
class IhrmEmpApi:

    # 添加员工
    @classmethod
    def add_emp(cls, resp_header, resp_data):
        resp_add = requests.post(url="http://ihrm-test.itheima.net/api/sys/user",
                                 headers=resp_header,
                                 json=resp_data)
        return resp_add

    # 查询员工
    @classmethod
    def query_emp(cls, emp_id, resp_header):
        resp_query = requests.get(url="http://ihrm-test.itheima.net/api/sys/user/" + emp_id,
                                  headers=resp_header)
        return resp_query

    # 修改员工
    @classmethod
    def modify_emp(cls, emp_id, resp_header, resp_data):
        resp_modify = requests.put(url="http://ihrm-test.itheima.net/api/sys/user/" + emp_id,
                                   headers=resp_header,
                                   json=resp_data)
        return resp_modify

    # 删除员工
    @classmethod
    def del_emp(cls, emp_id, resp_header):
        resp_del = requests.delete(url="http://ihrm-test.itheima.net/api/sys/user/" + emp_id,
                                   headers=resp_header)
        return resp_del


if __name__ == '__main__':
    resp_head = {"Authorization": "Bearer d5542092-c6ff-4f9b-b777-d9431927a4dc"}
    resp_data = {"username": "zs4", "mobile": "19874893714", "workNumber": "9527"}
    # print(IhrmEmpApi.add_emp(resp_head, resp_data).json())

    emp_id = '007'
    print(IhrmEmpApi.query_emp(emp_id, resp_head).json())

